package com.concurrence.chapter6;

import java.util.Arrays;
import java.util.function.IntConsumer;

/**
 * @Author: 陶鹏飞
 * @Description:
 * @Date: 2018/9/2-22:56
 * @email: taopengfei1223@foxmail.com
 **/
public class example_6_3 {
    private static int[] arr = {1,2,3,4,5,6,7};

    private static void version1() {
        for ( int i : arr ){
            System.out.println(i);
        }
    }

    private static void version2() {
        Arrays.stream(arr).forEach(new IntConsumer() {
            @Override
            public void accept(int value) {
                System.out.println(value);
            }
        });
    }

    private static void version3() {
        Arrays.stream(arr).forEach((final int x) -> {
            System.out.println(x);
        });
    }

    private static void version4() {
        Arrays.stream(arr).forEach((x) -> {
            System.out.println(x);
        });
    }

    private static void version5() {
        Arrays.stream(arr).forEach((x) -> System.out.println(x));
    }

    private static void version6() {
        Arrays.stream(arr).forEach(System.out::println);
    }

    public static void main(String[] args) {
//        version1();
//        version2();
//        version3();
//        version4();
//        version5();

        version6();
    }
}
